//
//  GGTSearchTableViewCell.m
//  GGT
//
//  Created by 空空空 on 14/11/3.
//  Copyright (c) 2014年 GGT. All rights reserved.
//

#import "GGTSearchTableViewCell.h"
#import "UIImageView+WebCache.h"
#import "GGTFind_BusinessesModel.h"

@implementation GGTSearchTableViewCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        self.imgView = [[UIImageView alloc]init];
        [self.contentView addSubview:self.imgView];
        //self.imgView.backgroundColor = [UIColor redColor];
        self.nameLabel = [[UILabel alloc]init];
        self.nameLabel.font = [UIFont fontWithName:@".HelveticaNeueInterface-Regular" size:19];
        [self.contentView addSubview:self.nameLabel];
        //self.titleLabel.backgroundColor = [UIColor grayColor];
        self.regionsLabel = [[UILabel alloc]init];
        self.regionsLabel.font = [UIFont fontWithName:@".HelveticaNeueInterface-Regular" size:16];
        self.regionsLabel.textColor = [UIColor lightGrayColor];
        [self.contentView addSubview:self.regionsLabel];
        //self.descriptLabel.backgroundColor = [UIColor grayColor];
        self.currentLabel = [[UILabel alloc]init];
        [self.contentView addSubview:self.currentLabel];
        self.categoriesLabel = [[UILabel alloc]init];
        self.categoriesLabel.font = [UIFont fontWithName:@".HelveticaNeueInterface-Regular" size:16];
        self.categoriesLabel.textColor = [UIColor lightGrayColor];
        [self.contentView addSubview:self.categoriesLabel];
        self.distanceLabel = [[UILabel alloc]init];
        [self.contentView addSubview:self.distanceLabel];
        
    }
    return self;
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    self.nameLabel.text = self.findModel.name;
    self.regionsLabel.text = self.findModel.regions;
    self.categoriesLabel.text = self.findModel.categories;
    self.currentLabel.textColor = [UIColor orangeColor];
    if ([self.findModel.avg_price integerValue]!= 0) {
        self.currentLabel.text = [NSString stringWithFormat:@"￥%@",self.findModel.avg_price];
    } else {
        
        self.currentLabel.text = @"价格详谈";
    }
    [self.imgView setImageWithURL:[NSURL URLWithString:self.findModel.imge] placeholderImage:[UIImage imageNamed:@"hold.png"]];
    
    
    self.imgView.frame = CGRectMake(10, 10, self.contentView.frame.size.width / 3, 100);
    self.nameLabel.frame = CGRectMake(self.contentView.frame.size.width / 3 + 20,0, self.contentView.frame.size.width / 3 * 2 - 50, self.contentView.frame.size.width / 9);
    self.regionsLabel.frame = CGRectMake(self.contentView.frame.size.width / 3 + 20, self.contentView.frame.size.height / 4, self.contentView.frame.size.width / 3 , self.contentView.frame.size.width / 5);
    self.categoriesLabel.frame = CGRectMake(self.contentView.frame.size.width / 3  + self.contentView.frame.size.width / 3, self.contentView.frame.size.height / 4, self.contentView.frame.size.width / 3, self.contentView.frame.size.width / 5);
    self.currentLabel.frame = CGRectMake(self.contentView.frame.size.width / 3 + 20, self.contentView.frame.size.height / 4 * 3, self.contentView.frame.size.width / 4, self.contentView.frame.size.width / 11);
    self.distanceLabel.frame = CGRectMake(280, 20, 40, 30);
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
